<?php
$mem = new Memcache;
$mem->connect('127.0.0.1', 11211);
$mem->set('key', 'This is a test!', 0, 60);
$val = $mem->get('key');
echo $val;

function get_memcache()
{
	$sql = "SELECT * FROM entries";
	$key = md5($sql);
	$mem = new Memcache;
	$mem->connect('127.0.0.1', 11211);
	if( ! ($result = $mem->get($key)))
	{
		echo 'Read datas from MySql','<br>';
		$query = $this->db->query($sql);
		foreach ($query->result() as $row)
		{
			$result[] = $row;
		}
		$mem->set($key,$result,0,60);
	}
	else
	{
		echo 'Read datas from memcache','<br>';
	}
	return $result;
	
}